Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hyperparameters for datamodule #3792

Merged

Conversation

tilman151
Copy link
Contributor

What does this PR do?

Fixes #3769

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together? Otherwise, we ask you to create a separate PR for every change.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

Tilman Krokotsch added 5 commits October 2, 2020 11:23
We want to use the hyperparameter saving code in the datamodule, too.
A DataModule can now save its hyperparameters just like a LightningModule.
The function takes a dict or namespace and adds the contained hparams to the existing ones. If a hparam already exists, an error is thrown to avoid overwriting it.
To log and checkpoint the hparams of the DataModule together with the model, we add them to the model's hparams before training.
@mergify mergify bot requested a review from a team October 2, 2020 12:37
@awaelchli awaelchli added feature Is an improvement or enhancement v1.0 post labels Oct 2, 2020
@edenlightning edenlightning added this to the 1.1 milestone Oct 4, 2020
@mergify
Copy link
Contributor

mergify bot commented Oct 5, 2020

This pull request is now in conflict... :(

@pep8speaks
Copy link

pep8speaks commented Oct 5, 2020

Hello @tilman151! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-07-09 14:38:05 UTC

@codecov
Copy link

codecov bot commented Oct 5, 2020

Codecov Report

Merging #3792 (d3d5cf7) into master (3102922) will decrease coverage by 5%.
The diff coverage is 98%.

@@           Coverage Diff           @@
##           master   #3792    +/-   ##
=======================================
- Coverage      93%     88%    -5%     
=======================================
  Files         215     216     +1     
  Lines       13988   14009    +21     
=======================================
- Hits        12965   12329   -636     
- Misses       1023    1680   +657     

@mergify
Copy link
Contributor

mergify bot commented Oct 7, 2020

This pull request is now in conflict... :(

@Borda Borda removed the v1.0 post label Oct 13, 2020
pytorch_lightning/utilities/hparams_mixin.py Outdated Show resolved Hide resolved
pytorch_lightning/utilities/hparams_mixin.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/trainer.py Outdated Show resolved Hide resolved
tests/models/test_hparams.py Outdated Show resolved Hide resolved
Copy link
Contributor

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great feature, very much looking forward to it! I tried it out and it works great!

I am convinced adding back the setter is the wrong decision. This will get us in the same trouble again that we had before we removed it. Please reconsider this change

tests/models/test_hparams.py Show resolved Hide resolved
pytorch_lightning/utilities/hparams_mixin.py Outdated Show resolved Hide resolved
pytorch_lightning/utilities/hparams_mixin.py Outdated Show resolved Hide resolved
Copy link
Member

@ethanwharris ethanwharris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, minor comment

pytorch_lightning/utilities/hparams_mixin.py Outdated Show resolved Hide resolved
Co-authored-by: Ethan Harris <ewah1g13@soton.ac.uk>
@kaushikb11
Copy link
Contributor

@Borda @tchaton Mind review?

@kaushikb11 kaushikb11 enabled auto-merge (squash) July 9, 2021 13:50
@mergify mergify bot added the has conflicts label Jul 9, 2021
@mergify mergify bot removed the has conflicts label Jul 9, 2021
Copy link
Member

@Borda Borda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kaushikb11 kaushikb11 merged commit 09ff295 into Lightning-AI:master Jul 9, 2021
@tilman151 tilman151 deleted the hyperparameters_for_datamodule branch July 9, 2021 15:10
@kaushikb11 kaushikb11 mentioned this pull request Jul 13, 2021
12 tasks
@s-rog
Copy link
Contributor

s-rog commented Aug 17, 2021

Should this be documented in the datamodule docs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hyperparameters for DataModules